package streamforce.crypto.cloud;


import com.espertech.esper.client.Configuration;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.EPStatement;
import com.espertech.esper.client.UpdateListener;
/**
 * Registering statement and adding listener
 */
public class EPCloud {
	static EPServiceProvider epService = null;	
	
	public EPServiceProvider initializeEPServiceProvider(){
		Configuration configuration = new Configuration();
		configuration.configure(EPCloudServer.CONFIG_FILE);		
		epService = EPServiceProviderManager
				.getDefaultProvider(configuration);
		return epService;
	}
	
	public void registerQueryPattern(String pattern, Object subscriber){
		/*EPStatement statement = this.epService.getEPAdministrator()
				.createPattern(pattern);*/
		EPStatement statement = epService.getEPAdministrator().createEPL(pattern);
		statement.setSubscriber(subscriber);		
	}
	
	public static EPServiceProvider getEPServiceProvider(){
		return epService;
	}
}
